<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.neuedu.web.entity.Role" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: jshand
  Date: 2022-10-26
  Time: 9:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>循环</title>
</head>
<body>

<%
    //模拟的调用Servlet从数据库中查询出来的集合，通过request 共享给jsp
    List<Role> list = new ArrayList();
    for (int i = 0; i < 10; i++) {
        list.add(new Role(i,"角色名字"+i,  i%3==0?1:0 ,new Date()));
    }
    list.add(new Role(99999,"特殊角色名字",  2,new Date()));
    request.setAttribute("roleList" ,list);


%>


<table cellspacing="0" cellpadding="0" border="1" width="90%">
    <tr>
        <th>序号</th>
        <th>角色名字</th>
        <th>是否有效</th>
        <th>创建角色时间</th>
        <th>操作</th>
    </tr>


<%--    <%--%>
<%--        List<Role> roleList = (List)request.getAttribute("roleList");--%>
<%--        for (int i = 0; i < roleList.size(); i) {--%>
<%--            Role role = roleList.get(i);--%>

<%--            pageContext.setAttribute("role",role);--%>
<%--    %>--%>




<%--    <c:forEach items="${roleList}" var="role" varStatus="stats" begin="2" end="8" step="2">--%>
    <c:forEach items="${roleList}" var="role" varStatus="stats" >
    <tr>
<%--        <td>${stats.index +1}</td>--%>
        <td>${stats.count}</td>
        <td><c:out value="${role.roleName}"></c:out> </td>
        <td>
<%--            <c:if test="${role.active == 0}">有效</c:if>--%>

            <c:choose>
                <c:when test="${role.active == 0}">有效</c:when>
                <c:when test="${role.active == 1}">无效</c:when>
                <c:otherwise>其他状态</c:otherwise>

            </c:choose>


        </td>
        <td>

<%--            <c:out value="${role.createtime}"></c:out> --%>
        
            <fmt:formatDate value="${role.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>
            
            
        </td>

        <td>操作</td>
    </tr>

    </c:forEach>


    <h3>forToken </h3>

    <c:set var="nameStr" value="google-runoob-taobao" scope="page"></c:set>

    <c:forTokens items="${nameStr}" delims="-" var="name" varStatus="stats">
       <div> ${stats.count}:   <c:out value="${name}"/><p>  </div>
    </c:forTokens>




</table>










</body>
</html>
